/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.guet.careapp.pojo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author LXM
 */
@Entity
@Table(name = "t_user_guardian_info")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TUserGuardianInfo.findAll", query = "SELECT t FROM TUserGuardianInfo t"),
    @NamedQuery(name = "TUserGuardianInfo.findByGId", query = "SELECT t FROM TUserGuardianInfo t WHERE t.gId = :gId"),
    @NamedQuery(name = "TUserGuardianInfo.findByUId", query = "SELECT t FROM TUserGuardianInfo t WHERE t.uId = :uId"),
    @NamedQuery(name = "TUserGuardianInfo.findByIdentifyNum", query = "SELECT t FROM TUserGuardianInfo t WHERE t.identifyNum = :identifyNum"),
    @NamedQuery(name = "TUserGuardianInfo.findByPhone", query = "SELECT t FROM TUserGuardianInfo t WHERE t.phone = :phone"),
    @NamedQuery(name = "TUserGuardianInfo.findByRemark", query = "SELECT t FROM TUserGuardianInfo t WHERE t.remark = :remark")})
public class TUserGuardianInfo implements Serializable {

    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "g_id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int gId;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "u_id")
    private Integer uId;
    @Size(max = 60)
    @Column(name = "identify_num")
    private String identifyNum;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="电话/传真格式无效, 应为 xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Size(max = 20)
    @Column(name = "phone")
    private String phone;
    @Size(max = 255)
    @Column(name = "remark")
    private String remark;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "gInfoId")
    private Collection<TServiceMessageInfo> tServiceMessageInfoCollection;
    @JoinColumn(name = "u_id", referencedColumnName = "u_id", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private TUserInfo tUserInfo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "gInfoId")
    private Collection<TUserRelation> tUserRelationCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "gInfoId")
    private Collection<TInstruction> tInstructionCollection;

    public TUserGuardianInfo() {
    }

    public TUserGuardianInfo(Integer uId) {
        this.uId = uId;
    }

    public TUserGuardianInfo(Integer uId, int gId) {
        this.uId = uId;
        this.gId = gId;
    }

    public int getGId() {
        return gId;
    }

    public void setGId(int gId) {
        this.gId = gId;
    }

    public Integer getUId() {
        return uId;
    }

    public void setUId(Integer uId) {
        this.uId = uId;
    }

    public String getIdentifyNum() {
        return identifyNum;
    }

    public void setIdentifyNum(String identifyNum) {
        this.identifyNum = identifyNum;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @XmlTransient
    public Collection<TServiceMessageInfo> getTServiceMessageInfoCollection() {
        return tServiceMessageInfoCollection;
    }

    public void setTServiceMessageInfoCollection(Collection<TServiceMessageInfo> tServiceMessageInfoCollection) {
        this.tServiceMessageInfoCollection = tServiceMessageInfoCollection;
    }

    public TUserInfo getTUserInfo() {
        return tUserInfo;
    }

    public void setTUserInfo(TUserInfo tUserInfo) {
        this.tUserInfo = tUserInfo;
    }

    @XmlTransient
    public Collection<TUserRelation> getTUserRelationCollection() {
        return tUserRelationCollection;
    }

    public void setTUserRelationCollection(Collection<TUserRelation> tUserRelationCollection) {
        this.tUserRelationCollection = tUserRelationCollection;
    }

    @XmlTransient
    public Collection<TInstruction> getTInstructionCollection() {
        return tInstructionCollection;
    }

    public void setTInstructionCollection(Collection<TInstruction> tInstructionCollection) {
        this.tInstructionCollection = tInstructionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (uId != null ? uId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TUserGuardianInfo)) {
            return false;
        }
        TUserGuardianInfo other = (TUserGuardianInfo) object;
        if ((this.uId == null && other.uId != null) || (this.uId != null && !this.uId.equals(other.uId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pojo.TUserGuardianInfo[ uId=" + uId + " ]";
    }
    
}
